using System;
using System.Collections.Generic;
using System.Timers;

namespace RxjhServer
{
	public class StarClass : IDisposable
	{
		private System.Timers.Timer EVFOi9BYj;

		private DateTime IFUB2YyLG;

		private string[] Nf6U2EcDs = World.幸运奖配置.Split(';');

		private System.Timers.Timer ns2shP2HQ;

		private static List<int> Oit6G76WW;

		private System.Timers.Timer timer_0;

		static StarClass()
		{
			old_acctor_mc();
		}

		public StarClass()
		{
			Oit6G76WW.Clear();
			IFUB2YyLG = DateTime.Now.AddMinutes(World.幸运奖倒计时间1);
			ns2shP2HQ = new System.Timers.Timer(60000.0);
			ns2shP2HQ.Elapsed += 发送幸运奖开始时间公告;
			ns2shP2HQ.Enabled = true;
			ns2shP2HQ.AutoReset = true;
			发送幸运奖开始时间公告(null, null);
			timer_0 = new System.Timers.Timer(World.幸运奖倒计时间2);
			timer_0.Elapsed += 幸运奖开始;
			timer_0.Enabled = true;
		}

		public void Dispose()
		{
			Oit6G76WW.Clear();
			if (ns2shP2HQ != null)
			{
				ns2shP2HQ.Enabled = false;
				ns2shP2HQ.Close();
				ns2shP2HQ.Dispose();
			}
			if (timer_0 != null)
			{
				timer_0.Enabled = false;
				timer_0.Close();
				timer_0.Dispose();
			}
			if (EVFOi9BYj != null)
			{
				EVFOi9BYj.Enabled = false;
				EVFOi9BYj.Close();
				EVFOi9BYj.Dispose();
			}
			World.幸运奖 = null;
		}

		private static void nC3Wo2agK()
		{
			Oit6G76WW = new List<int>();
		}

		private static void old_acctor_mc()
		{
			nC3Wo2agK();
		}

		public void 发送幸运奖开始时间公告(object sender, ElapsedEventArgs e)
		{
			try
			{
				int num = (int)IFUB2YyLG.Subtract(DateTime.Now).TotalSeconds;
				if (num != 0)
				{
					foreach (Players value in World.allConnectedChars.Values)
					{
						value.发送势力战开始倒计时(num);
						value.系统提示("离幸运奖开启还剩：" + (num / 60).ToString() + "分钟.请注意！！", 10, "广播");
					}
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "幸运奖 时间结束事件1 出错：" + ex?.ToString());
			}
		}

		public void 幸运奖开始(object sender, ElapsedEventArgs e)
		{
			ns2shP2HQ.Enabled = false;
			ns2shP2HQ.Close();
			ns2shP2HQ.Dispose();
			timer_0.Enabled = false;
			timer_0.Close();
			timer_0.Dispose();
			EVFOi9BYj = new System.Timers.Timer((double)int.Parse(Nf6U2EcDs[3]) * 60000.0);
			EVFOi9BYj.Elapsed += 幸运奖战结束;
			EVFOi9BYj.Enabled = true;
			new Random(DateTime.Now.Millisecond);
			float num = 1f + (float)int.Parse(Nf6U2EcDs[2]);
			float num2 = 1f + (float)int.Parse(Nf6U2EcDs[3]);
			new List<MonSterClss>();
			try
			{
				foreach (Players value in World.allConnectedChars.Values)
				{
					value.系统提示("幸运奖开始" + int.Parse(Nf6U2EcDs[3]).ToString() + " 分钟后，看看你是幸运玩家吗？", 10, "系统广播");
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "幸运奖 时间结束事件1 出错：" + ex?.ToString());
			}
		}

		public void 幸运奖战结束(object sender, ElapsedEventArgs e)
		{
			EVFOi9BYj.Enabled = false;
			EVFOi9BYj.Close();
			EVFOi9BYj.Dispose();
			try
			{
				List<Players> list = new List<Players>();
				foreach (Players value in World.allConnectedChars.Values)
				{
					list.Add(value);
				}
				Players players = list[new Random().Next(0, World.allConnectedChars.Count)];
				Players players2 = list[new Random().Next(0, World.allConnectedChars.Count)];
				string[] array = World.幸运奖奖励.Split(';');
				players.查百宝阁元宝数();
				players.百宝阁检察元宝数据(int.Parse(array[0]), 1);
				players.Player_WuXun += int.Parse(array[1]);
				players.FLD_RXPIONTX += int.Parse(array[2]);
				players.系统提示("你已经被系统随机选中，成为今天的幸运玩家！", 22, "幸运之神");
				players.系统提示("系统赠送您元宝：" + Convert.ToInt32(array[0]).ToString() + " 个！", 22, "幸运之神");
				players.系统提示("系统赠送您武勋：" + Convert.ToInt32(array[1]).ToString() + " 点！", 22, "幸运之神");
				players.系统提示("系统赠送您积分：" + Convert.ToInt32(array[2]).ToString() + " 个！", 22, "幸运之神");
				World.发送游戏特殊公告("恭喜，玩家：【" + players.UserName + "】，成为今天的幸运玩家。", 10, "幸运之神");
				players.保存人物的数据();
				players.保存元宝数据();
				players.保存积分数据();
				players.更新武勋效果();
				World.幸运奖.Dispose();
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "时间结束事件 幸运奖战结束 没有玩家在线 出错：" + ex?.ToString());
			}
		}
	}
}
